<template>
  <div class="order-right">
    <div class="order-content">
      <div class="title">
        <h3>我的订单</h3>
      </div>
      <div class="chosetype">
        <table>
          <thead>
            <tr>
              <th width="29%">商品</th>
              <th width="31%">订单详情</th>
              <th width="13%">收货人</th>
              <th>金额</th>
              <th>状态</th>
              <th>操作</th>
            </tr>
          </thead>
        </table>
      </div>
      <div class="orders">
        <!-- 每一笔订单 -->
        <table
          class="order-item"
          v-for="(order, index) in myOrder"
          :key="index"
        >
          <thead>
            <tr>
              <th colspan="5" class="ordertitle" v-show="order[1].allPrice!='0'">
                <span>订单时间：{{order[3].time}}</span>
                <span 
                  >
                  <span class="pull-right delete" @click="deleteRow(order)"
                    ><img src="../images/delete.png"
                  /></span>
                </span>
              </th>
            </tr>
          </thead>
          <tbody>
            <tr v-for="(item, index) in order[0]" :key="item.id">
              <td width="60%">
                <div class="typographic">
                  <img :src="item.defaultImg" style="width:100px;height:100px" />
                  <a href="#" class="block-text">{{ item.title }}</a>
                  <span>x{{ item.skuNum }}</span>
                  <a href="#" class="service">售后申请</a>
                </div>
              </td>
              <td
                :rowspan="5"
                v-if="index == 0"
                width="8%"
                class="center"
              >
               {{userInfo.nickname}}
              </td>
              <td
                :rowspan="5"
                v-if="index == 0"
                width="13%"
                class="center"
              >
                <ul class="unstyled">
                  <li>总金额¥{{ order[1].allPrice }}.00</li>
                  <li>在线支付</li>
                </ul>
              </td>
              <td
                :rowspan="5"
                v-if="index == 0"
                width="8%"
                class="center"
              >
                <a href="#" class="btn">支付成功</a>
              </td>
              <td
                :rowspan="5"
                v-if="index == 0"
                width="13%"
                class="center"
              >
                <ul class="unstyled">
                  <li>
                    <a href="mycomment.html" target="_blank">评价|晒单</a>
                  </li>
                </ul>
              </td>
            </tr>
          </tbody>
        </table>
      </div>
      <div class="choose-order">
        <!-- 分页器 -->
        <!-- <Pagination
          :pageNo="page"
          :pageSize="limit"
          :total="myOrder.total"
          :continues="5"
          @getPageNo="getPageNo"
        /> -->
      </div>
    </div>
    <!--猜你喜欢-->
    <div class="like">
      <h4 class="kt">猜你喜欢</h4>
      <ul class="like-list">
        <li class="likeItem">
          <div class="p-img">
            <img src="https://img-new.boqiicdn.com/Data/Shop/0/1/116/shoppicpath11567417979_y.jpg?imageView2/2/w/375/h/375/q/100/interlace/0/format/jpg" />
          </div>
          <div class="attr">
            <em>法国皇家Royal Canin 小型成犬粮 2kg</em>
          </div>
          <div class="price">
            <em>¥</em>
            <i>99.00</i>
          </div>
          <div class="commit">已有623人评价</div>
        </li>
        <li class="likeItem">
          <div class="p-img">
            <img src="https://img-new.boqiicdn.com/Data/Shop/0/1/139/shoppicpath11616392867_y.jpg?imageView2/2/w/375/h/375/q/100/interlace/0/format/jpg" />
          </div>
          <div class="attr">
            法国皇家Royal Canin 小型犬幼犬粮 2kg 
          </div>
          <div class="price">
            <em>¥</em>
            <i>126.00</i>
          </div>
          <div class="commit">已有526人评价</div>
        </li>
        <li class="likeItem">
          <div class="p-img">
            <img src="https://img-new.boqiicdn.com/Data/Shop/0/4/487/shoppicpath11616383560_y.jpg?imageView2/2/w/375/h/375/q/100/interlace/0/format/jpg" />
          </div>
          <div class="attr">法国皇家Royal Canin 小型犬幼犬离乳期奶糕粮 1kg </div>
          <div class="price">
            <em>¥</em>
            <i>68.00</i>
          </div>
          <div class="commit">已有764人评价</div>
        </li>
        <li class="likeItem">
          <div class="p-img">
            <img src="https://img-new.boqiicdn.com/Data/Shop/4/461/46174/shoppicpath11629102149_y.jpg?imageView2/2/w/375/h/375/q/100/interlace/0/format/jpg" />
          </div>
          <div class="attr">珍宝 经典鱼油全价成年期犬粮 1.5kg 营养多元 </div>
          <div class="price">
            <em>¥</em>
            <i>128.00</i>
          </div>
          <div class="commit">已有752人评价</div>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
export default {
  name: "",
  data() {
    return {
      //初始化参数
      //当前第几页
      page: 1,
      //每一页展示数据个数
      limit: 3,
      //存储我的订单的数据
      myOrder: {},
    };
  },
  mounted() {
    //获取我的订单的数据方法
    console.log(this.time);
    this.getData();
  },
  computed:{
    userInfo(){
      return this.$store.state.user.myData
    },
    time(){
      return JSON.parse(sessionStorage.getItem("time"));
    }
  },
  methods: {
    //获取我的订单的方法
    async getData() {
      //解构出参数
        this.myOrder = JSON.parse(sessionStorage.getItem("orderList"))
        // this.userInfo=JSON.parse(sessionStorage.getItem('userInfo')) 
    },
    //获取当前点击那一页
    deleteRow(order){
      // console.log(this.myOrder);
      // console.log(this.myOrder[0][2].id);
      this.myOrder.forEach((item,index) => {
        if (this.myOrder[index][2].id==order[2].id) {
          this.myOrder.splice(index,1)
        }
      });
      sessionStorage.setItem("orderList",JSON.stringify(this.myOrder));
      this.getData()
    }
  },
};
</script>

<style scoped>
.attr{
  width: 160px;
}
.price{
  margin-top: 6px;
}
.commit{
  margin-top: -8px;
}
</style>
